﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExtAspNet;
using System.Data;

namespace HY.WEB.SA
{
    public partial class zj_job_add : PageBase
    {
        public string us,um,tab="zj_job";
        protected void Page_Load(object sender, EventArgs e)
        {
            um = Session["user"].ToString();
            us = Session["ID"].ToString();
            if (!IsPostBack)
            {
                if (!String.IsNullOrEmpty(Request["stype"]))
                {
                     hidstype.Text = Request["sid"].Trim();                
                }
                if (!String.IsNullOrEmpty(Request["jbh"]))
                {
                    hidjbh.Text = Request["jbh"].Trim();
                }

                fill();
            }       
        }

        void fill()
        {
            //公司分类
            DataTable e = BLL.Bllbase.get_table("[zj]");
            ddlzj.Items.Clear();
            for (int i = 0; i < e.Rows.Count; i++)
            {
                ddlzj.Items.Add(new ExtAspNet.ListItem(e.Rows[i]["zname"].ToString().Trim(), e.Rows[i]["zbh"].ToString().Trim()));
            }
            ddlzj.DataBind();

            if (hidjbh.Text != "")     //学校    
                ddlzj.SelectedIndex = ddlzj.Items.IndexOf(ddlzj.Items.FindByValue(hidjbh.Text));
        }
        

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
          Model.SC.zjjob jb = new Model.SC.zjjob();

          jb.jbh = BLL.BllAutoCode.GetMaxBH("zj_job"); //岗位编号

          if (jb.jbh == "") return;

          jb.zbh = ddlzj.SelectedValue;
          jb.zname = ddlzj.SelectedText;
          jb.ztype = ddltype.SelectedValue;

          if (string.IsNullOrEmpty(date1.Text))
              date1.Text = "1900-01-01";

              if (string.IsNullOrEmpty(date2.Text))
                  date2.Text = "1900-01-01";

          jb.sdate = DateTime.Parse(date1.Text.Trim());
          jb.edate = DateTime.Parse(date2.Text.Trim());

          jb.zmemo = HttpUtility.HtmlEncode(memo.Text);
            
          BLL.SC.zjjob sco = new BLL.SC.zjjob();
          sco.Add(jb);
          //更新业务员操作记录
          BLL.Bllbase.update_rec(tab, um, " jbh='" + jb.jbh + "' ");

          Alert.Show("添加完成 ");
          PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }

       
    }
}